home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / jemtex2.zip / FONTABLE.C < prev    next >
C/C++ Source or Header  |  1991-04-14  |  6KB  |  179 lines

  1. /* -mt -f -A -K -G -O -w */
  2. /* Compile with Turbo-C 2.0 */
  3. /*
  4.   This program generates Japanese font tables
  5.  
  6.   Author: Francois Jalbert
  7.               '
  8.   Date: November 1990
  9.  
  10.   Version: 1.0
  11.  
  12.   Date: April 1991
  13.  
  14.   Version: 2.0
  15.  
  16.   Modifications: - Added four kanjis.
  17.                  - Run-time parameters now supplied.
  18.                  - Extension is .JEM now.
  19.                  - Page format changed slightly.
  20.                  - Symbols now centered within tables.
  21.                  - Switched to \clearpage since better for tables.
  22. */
  23.  
  24. #include <stdio.h>
  25. #ifdef __TURBOC__
  26. #include <process.h>
  27. #endif
  28.  
  29. /* Highest Bitmap number in JIS24 */
  30. #define BitmapMax  7806
  31. /* Highest font number */
  32. #define FontMax    60
  33. /* Number of symbols in a font */
  34. #define SymbolMax  128
  35. #define SymbolMax1 127
  36.  
  37. void FontTable(FILE *OutFile)
  38. {
  39.   int Bitmap;
  40.   int Font;
  41.   int Symbol;
  42.   unsigned char EUC1,EUC2;
  43.  
  44.   fprintf(OutFile,"%%JEM2TEX /NoSpace /NoPercent /LaTeX /EUC /Extended /3.0\n");
  45.   fprintf(OutFile,"%%\n");
  46.   fprintf(OutFile,"\\documentstyle[12pt]{article}\n");
  47.   fprintf(OutFile,"\\pagestyle{plain}\n");
  48.   fprintf(OutFile,"\\setlength{\\oddsidemargin}{-0.5in} %%0.5in margin left-right\n");
  49.   fprintf(OutFile,"\\setlength{\\textwidth}{7.5in} %%8.5in-2*0.5in\n");
  50.   fprintf(OutFile,"\\setlength{\\topmargin}{-0.25in} %%0.75in margin top-bottom\n");
  51.   fprintf(OutFile,"\\setlength{\\textheight}{9.4in} %%11.0in-2*0.75in\n");
  52.   fprintf(OutFile,"\\setlength{\\footskip}{0.1in}\n");
  53.   fprintf(OutFile,"\\setlength{\\footheight}{0.1in}\n");
  54.   fprintf(OutFile,"\\setlength{\\headheight}{0pt}\n");
  55.   fprintf(OutFile,"\\setlength{\\headsep}{0pt}\n");
  56.   fprintf(OutFile,"\\setlength{\\topskip}{0pt}\n");
  57.   fprintf(OutFile,"\\setlength{\\parindent}{0pt}\n");
  58.   fprintf(OutFile,"\\setlength{\\tabcolsep}{4pt}\n");
  59.   fprintf(OutFile,"\\renewcommand{\\baselinestretch}{0.85}\n");
  60.   fprintf(OutFile,"\\begin{document}\n");
  61.   fprintf(OutFile,"\\begin{Large}\n");
  62.   fprintf(OutFile,"\n");
  63.   fprintf(OutFile,"\\vspace*{\\fill}\n");
  64.   fprintf(OutFile,"\n");
  65.   if (ferror(OutFile)) exit(1);
  66.   for (Bitmap=0 ; Bitmap<=BitmapMax ; Bitmap++) {
  67.     Symbol=Bitmap % SymbolMax;
  68.     Font=Bitmap / SymbolMax;
  69.     EUC1=(unsigned char)((Bitmap-1)/94);
  70.     EUC2=(unsigned char)((Bitmap-1)-94*(int)EUC1);
  71.     EUC1=EUC1+(unsigned char)'\xA1';
  72.     EUC2=EUC2+(unsigned char)'\xA1';
  73.     if (!Symbol) {
  74.       fprintf(OutFile,"\\begin{table}[h]\n");
  75.       fprintf(OutFile," \\centering\n");
  76.       fprintf(OutFile," \\begin{tabular}{r|cccccccccccccccc|l}\n");
  77.       fprintf(OutFile,
  78.               "  Code & \\multicolumn{16}{c|}{Characters} & EUC \\\\ \\hline\n");
  79.       if (ferror(OutFile)) exit(1);
  80.     }
  81.     switch (Symbol % 16) {
  82.       case 0: fprintf(OutFile,"%6d ",Symbol);
  83.               if (ferror(OutFile)) exit(1);
  84.               break;
  85.       case 5: case 10: case 15: fprintf(OutFile,"       ");
  86.                                 if (ferror(OutFile)) exit(1);
  87.                                 break;
  88.     } 
  89.     if (Bitmap) {
  90.       fprintf(OutFile,"&%c%c",EUC1,EUC2);
  91.       if (ferror(OutFile)) exit(1);
  92.       switch (Symbol % 16) {
  93.         case 4: case 9: case 14: fprintf(OutFile,"\n"); 
  94.                                  if (ferror(OutFile)) exit(1);
  95.                                  break;
  96.         default:if ((Symbol % 16)==15) {
  97.                   fprintf(OutFile,"& %d,%d",EUC1,EUC2);
  98.                   if ( (Symbol!=SymbolMax1) && (Bitmap!=BitmapMax) )
  99.                     fprintf(OutFile," \\\\");
  100.                   fprintf(OutFile,"\n");
  101.                   if (ferror(OutFile)) exit(1);
  102.                 }
  103.                 else
  104.                   if (Bitmap==BitmapMax) {
  105.                     fprintf(OutFile,"\n");
  106.                     if (ferror(OutFile)) exit(1);
  107.                   }
  108.                 break;
  109.       } 
  110.     }
  111.     else {
  112.       fprintf(OutFile,"&  ");
  113.       if (ferror(OutFile)) exit(1);
  114.     }
  115.     if ( (Symbol==SymbolMax1) || (Bitmap==BitmapMax) ) {
  116.       fprintf(OutFile," \\end{tabular}\n");
  117.       fprintf(OutFile,"\\caption{Font {\\tt kanji%c%c} (%d--%d).}\n",
  118.               ('a'+(Font/8)),('a'+(Font % 8)),(Bitmap-Symbol),Bitmap);
  119.       fprintf(OutFile,"\\end{table}\n");
  120.       fprintf(OutFile,"\n");
  121.       if (ferror(OutFile)) exit(1);
  122.       if (Bitmap==BitmapMax) {
  123.         fprintf(OutFile,"\\vspace*{\\fill}\n");
  124.         fprintf(OutFile,"\n");
  125.         if (ferror(OutFile)) exit(1);
  126.       }
  127.       else
  128.         if ((Font % 3)==2) { 
  129.           fprintf(OutFile,"\\vspace*{\\fill}\n");
  130.           fprintf(OutFile,"\n");
  131.           fprintf(OutFile,"\\clearpage\n");
  132.           fprintf(OutFile,"\n");
  133.           fprintf(OutFile,"\\vspace*{\\fill}\n");
  134.           fprintf(OutFile,"\n");
  135.           if (ferror(OutFile)) exit(1);
  136.         }
  137.     }
  138.   }
  139.   fprintf(OutFile,"\\end{Large}\n");
  140.   fprintf(OutFile,"\\end{document}\n");
  141.   if (ferror(OutFile)) exit(1);
  142. }
  143.  
  144. main()
  145. {
  146.   FILE *OutFile;
  147.  
  148.   printf("\n");
  149.   printf("Japanese Font Tables Generation Program.\n");/*To make Borland happy*/
  150.   printf("Version 2.0 Copyright F. Jalbert 1991.\n");
  151.   printf("\n");
  152.   if (ferror(stdout)) exit(1);
  153.  
  154.   printf("Creating Japanese file fontable.jem");
  155.   if ((OutFile=fopen("fontable.jem","wt"))==NULL) exit(1);
  156.   printf(".\n");
  157.   if (ferror(stdout)) exit(1);
  158.  
  159.   printf("Generating font tables");
  160.   #ifndef __TURBOC__
  161.   printf("\n");
  162.   #endif
  163.   FontTable(OutFile);
  164.   printf(".\n");
  165.   if (ferror(stdout)) exit(1);
  166.  
  167.   printf("Closing Japanese file fontable.jem");
  168.   if (fclose(OutFile)==EOF) exit(1);
  169.   printf(".\n");
  170.   printf("\n");
  171.   if (ferror(stdout)) exit(1);
  172.  
  173.   printf("Japanese font tables generation completed.\n");
  174.   printf("\n");
  175.   if (ferror(stdout)) exit(1);
  176.  
  177.   return(0);
  178. }
  179.